# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=pyside2-tools
pkgbase=mingw-w64-${_realname}-qt5
pkgname=(${MINGW_PACKAGE_PREFIX}-${_realname}-qt5)
pkgdesc="PySide2 Tools (mingw-w64)"
pkgver=5.15.2
pkgrel=5
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://doc.qt.io/qtforpython-5/"
license=("LGPL")
depends=("${MINGW_PACKAGE_PREFIX}-qt5-base")
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-pyside2-qt5")
options=('staticlibs' 'strip')
source=(https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${pkgver}-src/pyside-setup-opensource-src-${pkgver}.tar.xz)
sha256sums=('b306504b0b8037079a8eab772ee774b9e877a2d84bab2dbefbe4fa6f83941418')

build() {
  [[ -d ${srcdir}/build-${MSYSTEM} ]] && rm -rf ${srcdir}/build-${MSYSTEM}
  mkdir -p ${srcdir}/build-${MSYSTEM} && cd ${srcdir}/build-${MSYSTEM}

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"Ninja" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DCMAKE_BUILD_TYPE=Release \
    -DPYTHON_EXECUTABLE=${MINGW_PREFIX}/bin/python.exe \
    ../pyside-setup-opensource-src-${pkgver}/sources/pyside2-tools

  ${MINGW_PREFIX}/bin/cmake.exe --build ./
}

package() {
  cd ${srcdir}/build-${MSYSTEM}
  DESTDIR=${pkgdir} ${MINGW_PREFIX}/bin/cmake.exe --install .

  rm ${pkgdir}${MINGW_PREFIX}/bin/{rcc,uic}.exe
}
